package com.hdbandit.multi_tenant;

import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.springframework.stereotype.Component;

import com.hdbandit.multi_tenant.util.RequestContextHolderUtils;

/**
 * 当前租户身份解析器的实现
 * @author Administrator
 *
 */
@Component
public class CurrentTenantIdentifierResolverImpl implements CurrentTenantIdentifierResolver {
    
	/**
	 * 从request中获取当前租户
	 */
     @Override
     public String resolveCurrentTenantIdentifier() {
         return RequestContextHolderUtils.getCurrentTenantIdentifier();
     }
    
     /**
      * Should we validate that the tenant identifier on "current sessions" that already exist when...
      * 我们是否应验证“当前会话”上的租户标识符是否已经存在,这里直接返回true,可查看父类的注释
      */
     @Override
     public boolean validateExistingCurrentSessions() {
         return true;
     }
}
